<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>用户管理</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<%@ include file="/common/css.jsp"%>
<!-- END GLOBAL MANDATORY STYLES -->
<link href="${ctx}/resource/css/promo.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/resource/css/animate.css" rel="stylesheet" type="text/css" />
<!-- BEGIN PAGE LEVEL STYLES -->
<link rel="stylesheet" type="text/css" href="${ctx}/resource/css/select2_metro.css" />
<link rel="stylesheet" href="${ctx}/resource/css/DT_bootstrap.css" />
<!-- END PAGE LEVEL STYLES -->
<link rel="shortcut icon" href="${ctx}/resource/image/logo2.png">
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed page-full-width">
	<!-- BEGIN HEADER -->
	<%@ include file="/common/header.jsp"%>
	<!-- END HEADER -->

	<div class="tab-pane row-fluid profile-account " id="tab_1_3" 
		style="margin-top: 40px">
		<div class="row-fluid ">
			<div class="span2"></div>
			<div class="span8">
				<h3 class="page-title">用户管理</h3>
				<ul class="breadcrumb">
					<li><i class="icon-home"></i> <a href="${ctx}/index.do">首页</a>
						<i class="icon-angle-right"></i></li>
					<li><a href="#">用户概况</a></li>
				</ul>
			</div>
		</div>

		<div class="span2"></div>

		<div class="span8" style="margin-left: 0; min-height: 600px">
 			<div class="row-fluid">
				<div class="span12 responsive" data-tablet="span12 fix-offset" data-desktop="span12">
						<!-- BEGIN EXAMPLE TABLE PORTLET-->
						<div class="portlet box blue">
							<div class="portlet-title">
								<div class="caption"><i class="icon-user"></i>用戶列表</div>
								<div class="actions">
									<button class="btn green" onclick="delAjax()"><i class="icon-pencil"></i> 删除</button>
								 </div>
							</div>

							<div class="portlet-body">
								<table class="table table-striped table-bordered table-hover" id="sample_2">
									<thead>
										<tr>
											<th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_2 .checkboxes" /></th>
											<th>Single ID</th>
											<th class="hidden-480">姓名</th>
											<th class="hidden-480">电话</th>
											<th class="hidden-480">邮箱</th>
										</tr>
									</thead>
									<tbody>
									<c:forEach var="users" items="${userpageList }">
										<tr class="odd gradeX">
											<td>
												<input type="checkbox"  class="checkboxes"  name="checkbox" value="" />
											</td>
											<td>${users.uid }</td>
											<td>${users.name }</td>
											<td>${users.mobile }</td>
											<td class="hidden-480"><a href="mailto:shuxer@gmail.com">${users.mail }</a></td>					
										</tr>
									</c:forEach>
									</tbody>
								</table>
							</div>
						</div>
						<!-- END EXAMPLE TABLE PORTLET-->
					</div>
					<div class="row-fluid">
						<div class="span6"></div>
						<div class="span6">
							<div class="dataTables_paginate paging_bootstrap pagination"> 
							<ul>
								<li class="">
									<a><b style="color: black">共${totalPage}页</b></a>
									<a href="${ctx }/user/manage.do?currentPage=0">
										<span class="hidden-480">首页</span>
									</a>
								</li>
								<%-- <c:forEach begin="1" end="${totalPage }" step="1" varStatus="key">  --%>
									<li>
										<c:choose>
											<c:when test="${currentPage==0 }">
												<a href="${ctx }/user/manage.do?currentPage=${currentPage }">上一页</a>
											</c:when>
											<c:when test="${currentPage > 0 }">
												<a href="${ctx }/user/manage.do?currentPage=${currentPage-1 }">上一页</a>
											</c:when>
										</c:choose>
											<a><b style="color: black">第${currentPage+1}页</b></a>
										<c:choose>
											<c:when test="${currentPage==totalPage-1}">
												<a href="${ctx }/user/manage.do?currentPage=${currentPage }">下一页</a>
											</c:when>
											<c:when test="${currentPage < totalPage-1 }">
												<a href="${ctx }/user/manage.do?currentPage=${currentPage+1 }">下一页</a>
											</c:when>
										</c:choose>
									</li>
								<%--</c:forEach> --%>
								<li class="next">
									<a href="${ctx }/user/manage.do?currentPage=${totalPage-1}">
										<span class="hidden-480">尾页</span>
									 </a>
								</li>
							</ul>
						</div>
						</div>
					</div>					
			</div>
			<!-- END PAGE CONTENT-->
	 	</div>
	</div>
	<!--end tab-pane-->
	<!-- BEGIN FOOTER1 -->
	<%@ include file="/common/footer.jsp"%>
	<!-- END FOOTER -->

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
	<!-- BEGIN CORE PLUGINS -->
	<script type="text/javascript" src="${ctx}/resource/js/dc.js"></script>
	<%@ include file="/common/js.jsp"%>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL PLUGINS -->
	<script type="text/javascript" src="${ctx}/resource/js/select2.min.js"></script>
	<script type="text/javascript" src="${ctx}/resource/js/jquery.dataTables.js"></script>
	<script type="text/javascript" src="${ctx}/resource/js/DT_bootstrap.js"></script>

	<!-- END PAGE LEVEL PLUGINS -->
	<script src="${ctx}/resource/js/app.js"></script>
	<script src="${ctx}/resource/js/table-managed.js"></script>
	<!-- END JAVASCRIPTS -->
	<script type="text/javascript">
		jQuery(document).ready(function() {       
		   App.init();
		   TableManaged.init();
		});
		
		function delAjax() {
		    var str="";
            $("input[name='checkbox']:checkbox").each(function(){ 
            	if ($(this).parent().hasClass("checked")) {
                    str += ($(this).parent().parent().parent()
					.next().text()+",").trim();
                }
            })
            str.split(",");//返回一个包含“，”的字符数组
            if(str==""){
            	//alert("err");
            	layer.msg("亲，至少选择一条数据哟！O(∩_∩)O~");
            }else{
            	$.ajax({
                	data:{"singleId":str},
                	dataType:"json",
                	url:"${ctx}/user/deleteUserById.do",
                	success:function(data){
                		if(data.flag){
                			window.location.href="${ctx}/user/manage.do?currentPage=0"
                		}
                	}
                })
            }
		}
	</script>
</body>
<!-- END BODY -->
</html>